package com.nature.ffmpegforandroid

import android.content.pm.PackageManager
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat

/**
 *User: RandBII
 *Date: 2021/1/4
 *Description:
 */
abstract class BaseActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContentView(getResourceId())

        initViews()

        initDatas()

    }

    abstract fun initViews()
    abstract fun initDatas()
    abstract fun getResourceId(): Int

    fun hasPermissions(permissions: Array<String>): Boolean {
        var has = true
        for (permission in permissions) {
            has = has and (ContextCompat.checkSelfPermission(
                this,
                permission
            ) == PackageManager.PERMISSION_GRANTED)
        }
        return has
    }

}